/**
 *
 */
package com.daocao.jy.util;

import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.amap.api.services.core.AMapException;

import com.daocao.jy.Application;
import com.daocao.jy.R;


public class ToastUtil {

    public static void show(Context context, String info) {
        makeText(context, info);
//        Toast.makeText(context.getApplicationContext(), info, Toast.LENGTH_SHORT).show();
    }

    public static void show(Context context, int info) {
        Toast.makeText(context, info, Toast.LENGTH_SHORT).show();
    }

    public static Toast makeText(Context context, CharSequence text) {
        Toast toast = new Toast(Application.getInstance());

        // 获取LayoutInflater对象
        LayoutInflater inflater = (LayoutInflater) Application.getInstance()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        // 由layout文件创建一个View对象
        View layout = inflater.inflate(R.layout.toast, null);

        TextView textView = (TextView) layout.findViewById(R.id.text);
        textView.setText(text);

        toast.setView(layout);
        toast.setGravity(Gravity.CENTER,0,0);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.show();
        return toast;
    }

}
